package de.hauck.rtmidlet.model;

import de.hauck.rtmidlet.utils.Utils;

/**
 * Class for configuration. Here are all configuration parameters stored as JavaBean. At least should...
 * @author Achim Hauck
 * 
 */
public class Configuration {
	
	public static final String RECORD_STORE_STOCKS_NAME = "Stocks";
	public static final String RECORD_STORE_CONFIG_NAME = "RTConfig";
	// Filter types for Display
	public static final String VERSION = "RT Depot v1.0";
	public static final String AUTHOR = "Achim Hauck";
	public static String exportURL = "file:///Speicherkarte/RTMidlet.csv";
	public static String exportPath = null;
	public static String importURL = "";
	public static final int FILTER_NONE = 0;
	public static final int FILTER_CHART_RT = 1;
	public static final int FILTER_CHART_FT = 2;
	public static final int FILTER_OVERVIEW_YAHOO = 3;

	public static final int RT = 0;
	public static final int TS = 1;
	public static final int INTRADAY = 2;
	public static final int FINANZTREFF = 3;

	public static final int CONN_STATUS_OFFLINE = 0;
	public static final int CONN_STATUS_CONNECTING = 1;
	public static final int CONN_STATUS_CONNECTED = 2;

	public static int ALERT_WAIT_TIME = 2000;

	// urls for charts
	public static String urlRT = "http://www.advfn.com/p.php?pid=staticchart&s=###&p=0&t=23&dm=0&vol=1";
	public static String urlTS = "http://extis.dab-bank.com/dab_neu/charts/detail_intrachart?type=time&tsOffset=0&sym1=###&crmbl=&lg=de&ct=de";
	public static String urlINTRADAY = "http://extis.dab-bank.com/dab_neu/charts/detail_intrachart?sym1=###&type=intra&ct=de&lg=de&height=202";
	public static String urlFINANZTREFF = "http://www.finanztreff.de/1/chartNG.gfn?u=100&lateIndex=1&overTime=3&chartType=8&time=0&highLow=1&newsType=1&raster=1&transactionVolumeUnit=1###&width=309&height=240";

	// urls for links in menu
	public static String linkFT = ""; 
	public static String linkOV = ""; 

	// Logging Parameters
	public static int logLevel = 0;
	public static boolean logOn = true;

	public static String initPath = "";
	private static long downloadCounter=0;
	private static long downloadSizeTotal=0;
	
	public static boolean dirtyFlagStocks=false;
	public static boolean dirtyFlagConfig=false;
	public static boolean fileWritingPossible=true;

	public static long getDownloadCounter() {
		return downloadCounter;
	}
	
	public static long getDownloadSizeTotal() {
		return downloadSizeTotal;
	}
	
	public static void setDownloadSizeTotal(long size) {
		downloadSizeTotal=size;
	}
	
	public static void addToDownloadCounter(long dc) {
		downloadCounter+=dc;
		downloadSizeTotal+=dc;
		dirtyFlagConfig=true;
	}
	
	public static void setInitPath(String path) {
		initPath = path;
	}

	public static String getURL(int type, String symbol) {
		String url="";
		switch (type) {
		case RT: {
			url=urlRT; break;
		}
		case TS: {
			url=urlTS; break;			
		}
		case INTRADAY: {
			url=urlINTRADAY; break;
		}
		case FINANZTREFF: {
			url=urlFINANZTREFF; 
			if (symbol.indexOf(".") == -1)
				symbol = "&instrumentId=" + symbol;
			else
				symbol = "&instrumentKey=" + symbol;
			break;
		}
		}
		return Utils.replace(url,"###", symbol);
	}
}
